package com.k8.common.ioc;

import com.k8.common.annotation.SPI;
import com.k8.common.ioc.injectorImpl.SafeObjectHolder;

import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;

@SPI
/**
 *
 * 默认是必须找到bean的，如果标注了{@link Required}，且值为false则可以不强制寻找
* */
public interface Injector {
    /*
     * 如果没找到，返回的Name应该为null
     * */
    boolean inject(Map<String,Object> relyBeanMaps, Object object , Field field);
    boolean needInject(Field field);

    /**
     *同步阻塞等待所有注入的属性实例化好
    * */
    void synJudge(Map<String, Object> relyBeanNames);

    <T> T getBean(final Map<String,SafeObjectHolder> relyBeanMaps, Class<T> clazz, String name);
    <T> T getBean(final Map<String,SafeObjectHolder> relyBeanMaps,Class<T> clazz);
    <T> T getBeanOrRegistry(final Map<String,SafeObjectHolder> relyBeanMaps,Class<T> clazz ,String name);
    <T> T getBeanOrRegistry(final Map<String,SafeObjectHolder> relyBeanMaps,Class<T> clazz);

    <T> List<T> getAllBeans(Map<String, SafeObjectHolder> relyBeanMaps, Class<T> clazz);

    <T> T getAdaptive(Map<String, SafeObjectHolder> relyBeanMaps, Class<T> clazz);
}
